const install = (Vue) => {
  const Bus = new Vue({
    methods: {
      // bus.$emit触发事件
      emit(event, ...args) {
        this.$emit(event, ...args)
      },

      // bus.$on监听触发的事件
      on(event, callback) {
        this.$on(event, callback)
      },

      off(event, callback) {
        this.$off(event, callback)
      }
    }
  })

  Vue.prototype.$bus = Bus
}

export default install
